(function () {
    'use strict';
    angular.module('module.business')
        .controller('ChangeRecordController', ChangeRecordController);
    ChangeRecordController.$inject = ['$rootScope', '$scope', '$filter', '$uibModal', '$http', '$state','$uibModalInstance', 'i18nService'];

    function ChangeRecordController($rootScope, $scope, $filter, $uibModal, $http, $state, $uibModalInstance, i18nService) {
        var vm = $scope;
        vm.activate = activate;     //初始化
        vm.cancel = cancel;//关闭弹窗
        vm.loadChangeRecordLabel =loadChangeRecordLabel;//加载列表页面

        vm.gridOptions = {
            multiSelect: true,                                           //多选
            enableRowSelection: true,                                  //允许选中行
            //showGridFooter:true,
            enableRowHeaderSelection: false,//允许通过点击行首选中行
            enableColumnResizing : true,//设置宽度
            enableGridMenu: true,
            enableFullRowSelection: true,                              //允许通过点击行任意位置选中行
            modifierKeysToMultiSelect: true,                           //只允许通过键盘辅助多选(前提是允许多选)
            paginationPageSize: 10,
            paginationPageSizes: [10, 20, 50]

        };
        i18nService.setCurrentLang('zh-cn');
        vm.gridOptions.onRegisterApi = onRegisterApi;

        vm.gridOptions.columnDefs = [
            {field: 'number', visible: true, name: '序号',width:'50', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'jiahao', visible: true, name: '', pinnedLeft: true,cellTooltip: true,headerTooltip: true, cellTemplate : '<i class="icon-plus"></i>'},
            {field: 'recordsTableNumber', visible: true, name: '变更申请人', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'subjectionRelationship', visible: true, name: '变更申请日期', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'unitType', visible: true, name: '变更内容', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'industryType', visible: true, name: '变更原因', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'unitConscientiousMan', visible: true, name: '变更审核人', pinnedLeft: true,cellTooltip: true,headerTooltip: true},
            {field: 'recordTime', visible: true, name: '变更审核时间', pinnedLeft: true,width:'150',cellTooltip: true,headerTooltip: true}
        ];


        activate();
        return vm;

        function activate() {
            loadChangeRecordLabel();
        }
        function onRegisterApi(gridApi) {
            //set gridApi on scope
            vm.gridApi = gridApi;
        }

        /**
         * 加载列表
         */
        function loadChangeRecordLabel(){
            $http.get('app/module/business/record/unit/record-unit.json')
                .then(function(data){
                    vm.gridOptions.data = data.data.changeRecord;
                });
        }
        /**
         * 关闭弹窗
         */
        function cancel() {
            $uibModalInstance.dismiss('cancel');
        }
    }
})();